<?php

$signature = $_GET['signature'];//获取get传递的参数
$timestamp = $_GET['timestamp'];
$nonce     = $_GET['nonce'];
$echostr   = $_GET['echostr'];
$token     ='ilife';//用户自己设置的token
$tmpArr    =array($token,$timestamp,$nonce);//构造数组将字符串放到里边
sort($tmpArr, SORT_STRING);//数组元素升降排序
$tmpStr=implode('', $tmpArr);//数组元素分隔为字符串
$return_str=sha1($tmpStr);//字符串sha1加密
if ($return_str==$signature) {
    echo $echostr;exit;
} else {
    return false;
}

